package ar.uba.fi.taller2.ftrs.tree;

import java.io.BufferedWriter;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.*;

/*****************************************************************************
 * <p>Title: CMSC420 </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2004</p>
 *
 * <p>Company: </p>
 *
 * @author sebastianrivas
 * @version 1.0
 ****************************************************************************/
public interface BSNode   {

  static byte GUIDE = 1;

  static byte LEAF  = 2;

   // devuelve un comparador
   Comparator comparator();

   //especifica si el nodo esta lleno o no
   boolean isFull();

   //devuelve la clave menor
   Object minKey();

   //devuelve  GUIDE OR LEAF
   int getType();

   //gets item at index
   // ****NOTE**** if its a guide node it returns the child at index
   // if its a leaf node it returns a record at index
   Object getItemAt(int index);

   //devuelve la key en un index
   Object getKeyAt(int index);

   //inserta  un nuevo item
   BSNode put(BSTree.Entry entry);

   // devuelve el tama�o ocupado
   int size();

   // shifts upwards
   BSNode shiftUp(int pos, int start);

   // fill factor
   int fillFactor();

   // remove
   BSNode remove(Object key);

   // decrece el tama�o
   void decreaseSize();

   // icrece el tama�o
   void increaseSize();

   //shifts upwards
   void shiftDown(int pos);

   // append a child or record to the end
   void append(Object o);

   // puts something at the beginning of the children or records
   void putFirst(Object o);

   // return the max size, either keys or records
   int maxSize();

   // return the max key
   Object maxKey();

   // changes the size, used after shifts
   void modifySize(int new_size);

   //returns the rightest child, applies only to guide node
   BSNode getLastChild();

   //returns min record
   BSTree.Entry getMinRecord();


   //imprime en pantalla en formato XML 
   void printXML();
   //imprime XML String en un arch xml
   void printXML(BufferedWriter file)throws IOException;
   void Print(String indent);

void readExternal(ObjectInput in) throws IOException, ClassNotFoundException;

void writeExternal(ObjectOutput out) throws IOException;

 String  getId();
}